<template>
  <div>
    <div>
      <FilterTable
        :isColumnFilter="false"
        :columns="columns"
        :dataSource="dataSource"
        :height="300"
        :onColumnsChange="columns => (this.columns = columns)"
        :onRowSelectChange="rowSelectChange"
      ></FilterTable>
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="alterHandle">新 增</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { generateLabourCode } from '@/api/repair/repair/labourManager';
import { querySeries } from '@/api/repair/basicparams/dealerAuthoriztion';
export default {
  name: 'seriesChoice',
  mixins: [dictionary],
  props: ['list'],
  data() {
    return {
      columns: this.createTable(),
      dataSource: [],
      dataList: []
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.querySeries();
  },
  methods: {
    createTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '车系代码',
          dataIndex: 'SERIES_CODE',
          minWidth: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
          showOverflowTooltip: true
        },
        {
          title: '车系',
          dataIndex: 'SERIES_NAME',
          minWidth: 200,
          sorter: true,
          filter: true,
          filterType: 'input',
          showOverflowTooltip: true
        }
      ];
    },
    async querySeries() {
      let type = [];
      this.list.forEach(x => {
        type.push(x.SERIES_CODE);
      });
      type.join();
      let res = await querySeries({ type: type });
      this.dataSource = res.data;
    },
    async closeDialog() {
      this.$emit('close');
    },
    async rowSelectChange(val) {
      this.dataList = val;
    },
    async alterHandle() {
      this.$emit('selectDate', this.dataList);
      this.$emit('close');
    }
  }
};
</script>

<style lang="less" scoped></style>
